package com.minivision.fdiot.listener;

import org.springframework.context.event.EventListener;
import org.springframework.data.redis.core.RedisKeyExpiredEvent;
import org.springframework.security.crypto.codec.Utf8;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * redis键过期事件监听器
 * @author hughzhao
 * @2018年3月1日
 */
@Component
@Slf4j
public class RedisKeyExpiredListener {
  
  /**
   * 监听redis键过期事件
   * @param event
   */
  @EventListener
  public void keyExpired(RedisKeyExpiredEvent<?> event) {
    log.warn("redis key[{}] expired, value:{}", event.getKeyspace() + ":" + Utf8.decode(event.getId()), event.getValue());
  }

}
